/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.pub.database.mysql;

/**
 *
 * @author gmlin
 */
public class MysqlFunction {

    public MysqlFunction(){}

    /**
     * 將多筆資料的SQL轉換為具分頁功能的SQL
     * @param pstrSQL String 原始SQL
     * @param pintMinRow int 此頁的起始列
     * @param pintPageSize int 此頁的筆數
     * @return String
     */
    public static String incPageSizeSQL(String pstrSQL,
                                        long plngStartRow,
                                        long plngPageSize) {
        StringBuffer lstbPageSizeSQL = new StringBuffer();
        try {
            lstbPageSizeSQL.append("");
            if (pstrSQL.trim().length() > 0) {
                lstbPageSizeSQL.append(pstrSQL);
                lstbPageSizeSQL.append(" limit ");
                lstbPageSizeSQL.append(plngStartRow);
                lstbPageSizeSQL.append(",");
                lstbPageSizeSQL.append(plngPageSize);
            }
        } catch (Exception ex) {
            System.out.println("\nMysqlFunction.java" +
                               " method:incPageSizeSQL --> Exception=" +
                               ex.toString());
        }
        return lstbPageSizeSQL.toString();

    }
}
